import 'package:flutter/material.dart';
import 'package:hook_up_rent/pages/search/widgets/data.dart';
import 'package:hook_up_rent/widgets/common_image.dart';
import 'package:hook_up_rent/widgets/common_tag.dart';

class RoomListItem extends StatelessWidget {
  final RoomListItemData roomListItemData;

  const RoomListItem(this.roomListItemData, {Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Row(
        children: [
          CommonImage(
            roomListItemData.imageUrl,
            width: 132.5,
            height: 100.0,
          ),
          Padding(padding: EdgeInsets.only(left:10.0)),
          _buildRoomListItemBoay()
        ],
      ),
    );
  }
  _buildRoomListItemBoay(){
    return Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                _buildRoomListItemBoayTitle(roomListItemData.title),
                _buildRoomListItemBoayTitle(roomListItemData.subTitle,isFontWeight: false),
                Wrap(
                    children: roomListItemData.tags
                        .map((item) => CommonTag(item))
                        .toList()),
                SizedBox(height:10),
                Text('${roomListItemData.price}元/月',style: TextStyle(color:Colors.orange,fontSize:16,fontWeight:FontWeight.w600),)
              ],
            ),
          );
  }
  Text _buildRoomListItemBoayTitle(String title,{bool isFontWeight = true}){
    TextStyle textStyle = TextStyle();
    if(isFontWeight){
      textStyle = TextStyle(fontWeight: FontWeight.bold);
    }
    return Text(title,style: textStyle,maxLines: 1, overflow: TextOverflow.ellipsis,);
  }
}
